package homework.api06;

import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class BwDemo {
    public static void main(String[] args) {
        try(
                FileOutputStream fos = new FileOutputStream("myNote.txt",true);
                OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
                BufferedWriter bw = new BufferedWriter(osw);
                PrintWriter pw = new PrintWriter(bw,true);
                ){
            Scanner scanner = new Scanner(System.in);
            while (true){
                System.out.println("请输入内容，单独输入exist退出：");
                String note = scanner.nextLine();
                if (note.equals("exist")){
                    break;
                }
                pw.println(note);
            }
        } catch (IOException e) {
            System.out.println("出现错误。");;
        }
    }
}
